package com.ruoyi.wbs.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.wbs.domain.WbsPlan;
import com.ruoyi.wbs.service.IWbsPlanService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * WBS计划Controller
 * 
 * @author renyuixn
 * @date 2024-06-06
 */
@RestController
@RequestMapping("/wbs/wbsPlan")
public class WbsPlanController extends BaseController
{
    @Autowired
    private IWbsPlanService wbsPlanService;

    /**
     * 查询WBS计划列表
     */
    @PreAuthorize("@ss.hasPermi('wbs:wbsPlan:list')")
    @GetMapping("/list")
    public TableDataInfo list(WbsPlan wbsPlan)
    {
        startPage();
        List<WbsPlan> list = wbsPlanService.selectWbsPlanList(wbsPlan);
        return getDataTable(list);
    }

    /**
     * 导出WBS计划列表
     */
    @PreAuthorize("@ss.hasPermi('wbs:wbsPlan:export')")
    @Log(title = "WBS计划", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WbsPlan wbsPlan)
    {
        List<WbsPlan> list = wbsPlanService.selectWbsPlanList(wbsPlan);
        ExcelUtil<WbsPlan> util = new ExcelUtil<WbsPlan>(WbsPlan.class);
        util.exportExcel(response, list, "WBS计划数据");
    }

    /**
     * 获取WBS计划详细信息
     */
    @PreAuthorize("@ss.hasPermi('wbs:wbsPlan:query')")
    @GetMapping(value = "/{wbsId}")
    public AjaxResult getInfo(@PathVariable("wbsId") Long wbsId)
    {
        return success(wbsPlanService.selectWbsPlanByWbsId(wbsId));
    }

    /**
     * 新增WBS计划
     */
    @PreAuthorize("@ss.hasPermi('wbs:wbsPlan:add')")
    @Log(title = "WBS计划", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WbsPlan wbsPlan)
    {
        return toAjax(wbsPlanService.insertWbsPlan(wbsPlan));
    }

    /**
     * 修改WBS计划
     */
    @PreAuthorize("@ss.hasPermi('wbs:wbsPlan:edit')")
    @Log(title = "WBS计划", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WbsPlan wbsPlan)
    {
        return toAjax(wbsPlanService.updateWbsPlan(wbsPlan));
    }

    /**
     * 删除WBS计划
     */
    @PreAuthorize("@ss.hasPermi('wbs:wbsPlan:remove')")
    @Log(title = "WBS计划", businessType = BusinessType.DELETE)
	@DeleteMapping("/{wbsIds}")
    public AjaxResult remove(@PathVariable Long[] wbsIds)
    {
        return toAjax(wbsPlanService.deleteWbsPlanByWbsIds(wbsIds));
    }
}
